#include <iostream>
using namespace std;
#include <stdio.h>


/* vector就是动态数据*/
#include <vector>

int swapData(int *nums1, int *nums2)
{
    int temp = 0;
    temp = *nums1;
    *nums1 = *nums2;
    *nums2 = temp;

    return 0;


}

int main()
{
    vector <int> myvec;

    myvec.push_back(11);
    myvec.push_back(22);
    myvec.push_back(33);

    /* 查看动态数组的元素个数*/
    int len = myvec.size();
    printf("len:%d\n", len);

    int cap = myvec.capacity();
    printf("cap:%d\n", cap);

    myvec.push_back(44);
    myvec.push_back(55);

    cap = myvec.capacity();
    printf("cap:%d\n", cap);

    for(int idx = 0; idx < myvec.size(); idx++)
    {
        printf("myvec[%d] = %d\n", idx, myvec.at(idx));
    }


    /* 数组逆序*/
    int end = myvec.size() - 1;
    for(int idx = 0; idx < myvec.size() >> 1; idx++)
    {
        /* myvec.at(idx) 和 myvec.at(end)交换*/
        swapData(&(myvec.at(idx)), &(myvec.at(end))); 
        end--;

    }
    for(int idx = 0; idx < myvec.size(); idx++)
    {
        printf("myvec[%d] = %d\n", idx, myvec.at(idx));
    }
    printf("\n");

    return 0;

}